using Geek.Server.Core.Serialize;
using MongoDB.Bson.Serialization.Attributes;


public abstract class HttpRequest
{
    /// <summary>
    /// 路由 用于拼接api地址 完整api地址=ip:port/game?api=Route
    /// </summary>
    [BsonIgnore]
    public abstract string Route { get; }

    /// <summary>
    /// 兼容客户端引用对象的清理接口
    /// </summary>
    public abstract void OnRecycle();
}

public class HttpResponse : IResponse
{
    /// <summary>
    /// 错误码
    /// </summary>
    public int ErrorCode { get; set; }

    public virtual void OnRecycle()
    {
        ErrorCode = 0;
    }

    public override string ToString()
    {
        return this.ToJsonStr();
    }

    public static implicit operator string(HttpResponse value)
    {
        return value.ToString();
    }

    public static HttpResponse Create(int errorCode = 0)
    {
        return new HttpResponse
        {
            ErrorCode = errorCode
        };
    }
}